package device

import "errors"

var (
	ErrDeviceHandleNotFound  = errors.New("device handle not found")
	ErrConnectRecordNotFound = errors.New("connect record not found")
	ErrConnectRecordGetFail  = errors.New("connect record get fail")
	ErrConnectRecordInvalid  = errors.New("connect record invalid")
	ErrConnectRecordBusy     = errors.New("connect record busy")
)

type DeviceID uint32
type DeviceData []byte
type ConnectID uint32
type ConnectData []byte

type ConnectStatus struct {
	IsAvaliable bool        //can be data source
	Spec        ConnectData //use data to show connect properties,make uuid
}

type DeviceManager interface {
	DeviceCreate([]byte) error
	DeviceDestroy(DeviceID) error
	DeivceCheck() (map[DeviceID]DeviceData, error)

	DeviceConnectCreate(DeviceID, []byte) error     //when lowlayer support
	DeviceConnectDestroy(DeviceID, ConnectID) error //when lowlayer support
	DeviceConnectCheck(DeviceID) (map[ConnectID]*ConnectStatus, error)
	DeviceConnectTransimit(DeviceID, ConnectID, []byte) error
	DeviceConnectReceive(DeviceID, ConnectID) ([]byte, error)
}

type connectController interface {
	/* put 32bits uuidv4 to create*/
	ConnectCreate([]byte) error
	ConnectDestroy(ConnectID) error
	ConnectCheck() (map[ConnectID]*ConnectStatus, error)
	ConnectTransimit(ConnectID, []byte) error
	ConnectReceive(ConnectID) ([]byte, error)
}
